package com.tfy.liquor.dao;

import com.tfy.liquor.bean.UserPriseRecords;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Mapper
@Service
public interface UserPriseRecordsDao {
    // 添加数据
    @Insert("insert into user_prise_records values(null, ${userId}, ${amount}, ${afterAmount}, '${orderId}', '${type}', '${createTime}', '${remark}')")
    int addUserPriseRecords(UserPriseRecords userPriseRecords);

    // 获取记录信息
    @Select("<script>" +
            "select * from user_prise_records " +
            "where 1=1" +
            "<if test='userId != null'>and userId = ${userId}</if>" +
            "<if test='orderId != null'>and orderId = '${orderId}'</if>" +
            "<if test='type != null'>and type = '${type}'</if>" +
            "<if test='createTime != null'>and createTime LIKE '%${createTime}%'</if>" +
            "<if test='remark != null'>and remark LIKE '%${remark}%'</if>" +
            "order by id desc" +
            "</script>")
    ArrayList<UserPriseRecords> getUserPriseRecords(UserPriseRecords userPriseRecords);

}
